<?
session_start();
if(isset($_POST['entrar']))
	{
	$user = $_POST['usuario'];
	$pass = $_POST['pass'];
	require('abrirdb.php');
	$busca = mysql_query("SELECT * FROM cliente where email = '$user' and pass = '$pass'");
	if(mysql_num_rows($busca)==1)
		{
		$array = mysql_fetch_array($busca);
		#Registramos sesiones y nos vamos al perfil con opcion a Editar
		$_SESSION['tipo'] = $array['tipo'];
		$_SESSION['id_cliente'] = $array['id_cliente'];
		$_SESSION['nombre'] = $array['nombre'];
		$script = '<SCRIPT language="Javascript" type="text/javascript">parent.document.location="miperfil.php";</script>';
		}
	else
		{$response = '<tr><td colspan="2">Error, Intenta de nuevo</td></tr>';}
	}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Autos Y Refacciones</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<?=$script;?>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<table width="269" height="185" border="0" align="center" cellpadding="0" cellspacing="0">
	<?=$response;?>
  	<tr>
  	  <td colspan="2" class="babyblue">Bienvenido...</td>
    </tr>
  	<tr><td width="112" class="black12" align="right">Correo electrònico:</td>
    	<td width="138"><input name="usuario" type="text" class="gray12" id="usuario" /></td></tr>
  <tr><td class="black12" align="right">Contraseña:&nbsp;</td>
    	<td><input name="pass" type="text" class="gray12" id="pass" /></td></tr>
  <tr>
    <td colspan="2"><div align="center">
      <input name="entrar" type="submit" class="gray12" id="entrar" value="Iniciar Sesión " />
    </div></td>
  </tr>
  <tr><td colspan="2"><div align="center"><a href="recordar.php">¿Ha olvidado la contraseña?</a></div></td></tr>
</table>
</form>
</body>
</html>
